import 'package:flutter/material.dart';
import 'package:flutter_time_manager/pages/add_todo_page.dart';

import 'package:flutter_time_manager/pages/canvas_demo.dart';
import 'package:flutter_time_manager/pages/carousel_demo.dart';
import 'package:flutter_time_manager/pages/image_picker_demo.dart';
import 'package:flutter_time_manager/pages/page_state_demo.dart';
import 'package:flutter_time_manager/pages/setting_page.dart';
import 'package:flutter_time_manager/pages/todo_list_page.dart';
import 'package:flutter_time_manager/state/count_state.dart';
import 'package:flutter_time_manager/state/user_state.dart';
import 'package:flutter_time_manager/state/time_manager_state.dart';
import 'package:provider/provider.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(builder: (_) => Counter()),
        ChangeNotifierProvider(builder: (_) => TimeManager()),
        ChangeNotifierProvider(builder: (_) => UserState()),
      ],
      child: Consumer<TimeManager>(
        builder: (context, manager, _) {
          return MaterialApp(
            routes: {
              "/demo02": (context) => PageStateDemo02(),
              "/CarouselDemo": (context) => CarouselDemo(),
              "/TodoListPage": (context) => TodoListPage(),
              "/canvasDemo": (context) => CanvasDemo(),
              "/SettingPage": (context) => SettingPage(),
              "/ImagePickerDemo": (context) => ImagePickerDemo(),
              "/AddTodoPage": (context) => AddTodoPage(),
            },
            locale: Locale('zh', 'CN'),
            localizationsDelegates: [
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
            ],
            supportedLocales: [
              Locale('zh', 'CN'),
            ],
            theme: ThemeData(
              primaryColor: Color(0xfffefefe),
              primarySwatch: Colors.grey,
            ),
            home: TodoListPage(),
          );
        },
      ),
    );
  }
}
